package com.lightjet.macross.base.upms.domain;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.lightjet.macross.common.core.IntKeyBaseEntity;
import com.lightjet.macross.common.core.StringKeyBaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * @author : lijia
 * @version : 1.0 2018-10-02 15:26
 * description :系统用户实体类
 */
@Entity
@Table(name="SYS_USER",uniqueConstraints ={@UniqueConstraint(columnNames={"username"})})
@Getter
@Setter
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler","createDate","updateDate"})
//@ApiModel(description = "系统平台默认自带的用户体系实体类")
public class SysUser extends StringKeyBaseEntity {
    public SysUser(){}

    public SysUser(String id)
    {
        this.id = id;
    }

    public SysUser(String id,String displayname)
    {
        this.id = id;
        this.displayname = displayname;
    }

    public static enum UserStateEnum {
        LOCKED,
        NORMAL,
        INVALID,
        INACTIVE
    }
    //@ApiModelProperty(value = "用户（账号）名")
    @Length(min=4,max=50,message = "用户名长度为4-50")
    private String username;//帐号

    //@ApiModelProperty(value = "用户显示名称")
    @Length(min=1,max=50,message = "用户显示名称不能为空" )
    private String displayname;//显示名称

    @JsonBackReference
    //@ApiModelProperty(value = "用户密码")
    private String password;//密码
    @JsonIgnore

    //@ApiModelProperty(value = "加密密码的盐")
    @JsonBackReference
    private String salt;//加密密码的盐

    //@ApiModelProperty(value = "用户工号")
    private String workno;//工号

    //@ApiModelProperty(value = "用户状态")
    @Enumerated(EnumType.ORDINAL)
    private UserStateEnum userstate;//用户状态,0:创建未认证（比如没有激活，没有输入验证码等等）--等待验证的用户 , 0:正常状态,1：用户被锁定.

    /** description:账户所属单位  */
    //@ApiModelProperty(value = "账户所属单位")
    @ManyToOne
    @JoinColumn(name="affiliationid")
    private SysOrganization affiliation;

    //@ApiModelProperty(value = "用户状态")
    private String email;//邮箱地址

    //@ApiModelProperty(value = "用户状态")
    private String unicode;//邮箱地址

    //@ApiModelProperty(value = "头像url")
    private String imgurl;//头像url  */

    //@ApiModelProperty(value = "上次登录时间")
    private Date lastloginttime; //上次登录时间

    //@ApiModelProperty(value = "上次登录ip")
    @Column(length = 20)
    private String lastlogiip;//上次登录ip

    //@ApiModelProperty(value = "备注信息")
    private String memo;//备注信息

    //@ApiModelProperty(value = "保留字段1")
    private String reserved1;//保留字段1

    //@ApiModelProperty(value = "保留字段2")
    private String reserved2;//保留字段2

    //移动电话
    //@Column(unique =true)
    //@ApiModelProperty(value = "移动电话")
    private String mobile;



}